<?php require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($_SERVER['DOCUMENT_ROOT']."/Modules/MGK20XF5/moduleconf.php");
MYDCONN();
$GLOBALS['MYT']=$GLOBALS['MYD'];
	$PR_Qur = " AND TYPE = 1 AND Time > '".date("Y-m-01")." 00:00:00'";
	if (isset($_GET['Time'])) {
		$PR_Qur = " AND TYPE = 1 AND Time > '{$_GET['Time']} 00:00:00'";
	}
	if (isset($_GET['DCTP'])) {
		$PR_Qur = " AND TYPE = {$_GET['DCTP']}";
	}
	if(isset($_GET['ddocArea']) && $_GET['ddocArea']>0){
		$PR_Qur = " AND ddocArea = {$_GET['ddocArea']}";
	} else {
		$_GET['ddocArea'] = 0;
	}
form_pr('doccenter_show','','','post');
	mn_field('hidden','ED','requestreq_Note','','','','','');
	echo '<div class="title">
	<div style="margin:2px;padding:4px;border:1px solid #CCC">Departamento: ';
	mn_field('select','ED','ddocArea',$_GET['ddocArea'],"SELECT ref AS ID, NAME FROM main_offices WHERE ref_domain=0 OR office_number = 800",' ','','" onchange="
		replaceUrl(\'hc_contents\',\'Modules/MGK20XF5/mdocs.php?ddocArea=\'+this.value);');
	echo '</div>
	<table width="100%" bgcolor="#FFFFFF" border="0" cellpadding="2" cellspacing="1">';

  if (!isset($_GET['Iv'])) { 
  
  echo '<tr bgcolor="#F2F2F2">
  	<td width="3%">N.</td>
  	<td width="5%">Tipo</td>
    <td width="25%">Título</td>
    <td width="8%">Data</td>
    <td width="10%">Autor</td>
    <td width="6%">Responsavel</td>
  </tr>';

    $Results = $GLOBALS['MYD']->db_array("SELECT 
					USER,
					a.Ref,
					a.Title,
					a.Body,
					a.Time,
					a.Author,
					a.DocRefer,
					reportreq_Note,
					sug_Name AS Attrib,
					hcdc_types.NAME AS TYPE
				FROM doccenter_document AS a
				INNER JOIN hcdc_types ON hcdc_types.REF = a.TYPE
				INNER JOIN sys_usergroups ON sug_ID = a.Attrib
				LEFT OUTER JOIN doccenter_userreads ON DOC = a.Ref AND USER = {$_SESSION[$SESSID]}
				WHERE STATUS = 1
				{$PR_Qur}
				ORDER BY a.Ref DESC"); 
	for ($f = 1; $f <= $Results[0]; $f++) { 
	
		echo'<tr style="border-top:1px solid #CCC" height="25" onclick="replaceUrl(\'hc_contents\',\'Modules/MGK20XF5/mdocs.php?Iv='.$Results[$f]['Ref'].'\');" ';
		if (isset($Results[$f]['USER'])) { echo 'bgcolor="#00CC33"'; } echo '>
		<td>'.$Results[$f]['DocRefer'].'</td>
		<td>'.$Results[$f]['TYPE'].'</td>
		<td>'.$Results[$f]['Title'].'</td>
		<td>'.$Results[$f]['Time'].'</td>
		<td>'.$Results[$f]['Author'].'</td>
		<td>'.$Results[$f]['Attrib'].'</td>
		</tr>';
   }  
	echo '</table>';
   } else {
	echo '<tr bgcolor="#D3D6E4">
		<td height="25" colspan="5">^ Listagem de Documentos Minimizada | <a onclick="replaceUrl(\'hc_contents\',\'Modules/MGK20XF5/mdocs.php?jB=4\');"><b>Maximizar (+)</b></a></td>
		</tr></table>'; 
	include($MODPAD.'lib/frm_document.php');
	}?>
</div></form>
